package com.useeinfo.oa.modules.base.entity;

import com.alibaba.fastjson.JSONObject;
import com.useeinfo.framework.extend.entity.SuperClassEntity;
import com.useeinfo.oa.modules.security.entity.SystemUser;

import javax.persistence.*;

/**
 * @program: YiYouFuPlatform
 * @author: Taogq
 * @createDate: 2018-12-14
 * @createTime: 13:50:00
 * 人员与组织架构关系----是否是主管
 */
@Entity
@Table(name = "SystemUserOrganization")
public class SystemUserOrganization extends SuperClassEntity<SystemUserOrganization> {

    /**
     * 人员
     */
    @ManyToOne
    @JoinColumn(name = "systemUser_id")
    private SystemUser systemUser;

    /**
     * 组织架构
     */
    @ManyToOne
    @JoinColumn(name = "organization_id")
    private Organization organization;

    /**
     * 是否为部门主管  0不是 1是
     */
    @Column(columnDefinition = "bit default 0")
    private boolean leader;

    public SystemUser getSystemUser() {
        return systemUser;
    }

    public void setSystemUser(SystemUser systemUser) {
        this.systemUser = systemUser;
    }

    public Organization getOrganization() {
        return organization;
    }

    public void setOrganization(Organization organization) {
        this.organization = organization;
    }

    public boolean isLeader() {
        return leader;
    }

    public void setLeader(boolean leader) {
        this.leader = leader;
    }

    @Override
    public JSONObject toJSONObject() {
        JSONObject jsonObject = super.toJSONObject();
        jsonObject.put("leader",isLeader());
        return jsonObject;
    }
}
